import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 存储token 或用户信息
    Authorization: localStorage.getItem('zf_Authorization') ? localStorage.getItem('zf_Authorization') : '',
    PayeeUser: localStorage.getItem('zf_PayeeUser') ? localStorage.getItem('zf_PayeeUser') : '',
    Token:localStorage.getItem('token') ? localStorage.getItem('token') : '',
  },
  mutations: {
    //注册处理函数，在login组件的login方法上使用this.$store.commit('login',data);
    login(state, user) {
      state.Authorization = user;      
      localStorage.setItem('zf_Authorization', user);      
    },
    settoken(state,token){
      state.Token = token;
      localStorage.setItem('token', token);
    },
    setPayee(state,user){
      state.PayeeUser = user;
      localStorage.setItem('zf_PayeeUser', user)
    }
  },
  actions: {
  },
  modules: {
  }
})
